home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Ubisoft Digital Press Ki….S.A./North America (USA)
/
Ubisoft Digital Press Kit 99 U.S.A.-North America (USA).bin
/
Dcr
/
language2.cst
/
00004_Script_Scroll Text Beh
< prev
next >
Wrap
Text File
|
1999-05-03
|
3KB
|
101 lines
-- Scroll Text Behavior
---------------------------------------------------------------
-- This behavior the text in response to messages from the
-- arrow buttons, track, or indicator.
--
-- You attach this behavior to a text sprite.
--
-- 10/22/97 David Benman
---------------------------------------------------------------
-- pTextSprite - the behavior's sprite.
-- pTextMember - member reference for the text member in the sprite.
-- pTextLowerLimit - lower limit for the text scrolling.
-- pTextRange - entire range the text scrolls.
-- pLineSize - the amount the text scrolls when the
-- user clicks a button once. Usually the line height.
property onetime, pTextSprite, pTextMember, pTextLowerLImit, pTextRange, pLineSize, pPageSize, pTextOrigin
on beginsprite me
set onetime to 1
end
-- This handler initializes several properties, sets the limits
-- for the text scrolling, and scrolls the text to its beginning
-- position.
on exitframe me
if onetime = 1 then
set pLineSize to 13
set totalLines to 15
set pPageSize to totalLines * pLineSize
set pTextOrigin to 255
set pTextSprite to the spriteNum of me
set pTextMember to the member of sprite pTextSprite
set lastOffset to integer(0.5 * totalLines) * plineSize
set textUpperLimit to the height of member pTextMember - lastOffset
set pTextLowerLimit to 0
set pTextRange to textUpperLimit - pTextLowerLimit
set the locV of sprite pTextSprite to pTextOrigin
set onetime = onetime + 1
end if
end
-- This handler scrolls the text in response to messages from the
-- arrow buttons, track, or indicator.
-- direction - either a symbol indicating the direction of scrolling
-- or a proportion to indicate a specific position.
-- scrollType - contains the symbol #page when scrolling should
-- be by page.
on scrollText me, direction, scrollType
-- Sets the scrollAmount either a line or page depending on
-- the value for scrollType.
case TRUE of
(voidP(scrollType)):
set scrollAmount to pLineSize
(scrollType = #page):
set scrollAmount to pPageSize
end case
-- Determines the next scroll position for the text. Sets the
-- next position to plus or minus one line, one page, or a specific
-- position depending on the value of direction.
if symbolP(direction) then
case direction of
#down: set scrollDirection to 1
#up: set scrollDirection to -1
end case
set scrollVector to scrollAmount * scrollDirection
set currentPosition to pTextOrigin -the locV of sprite pTextSprite
set nextPosition to currentPosition + scrollVector
if nextPosition > pTextLowerLimit + pTextRange then
set nextPosition to pTextLowerLimit + pTextRange
else
if nextPosition < pTextLowerLimit then
set nextPosition to pTextLowerLimit
end if
end if
else
set nextPosition to direction * pTextRange
end if
-- Sets the text to the next position.
set the locV of sprite pTextSprite to pTextOrigin - nextPosition
-- Sends a message to position the indicator to match the text.
sendAllSprites(#positionIndicator, float(nextPosition)/pTextRange)
end